<template>
    <div class="gameindex" ref="gameindex">
        <scroll class="index-wrapper" :listenScroll=true>
            <div>
                <slider v-if="adsList.length">
                    <div v-for="(item,index) in adsList" :key=index>
                        <a href="http://www.baidu.com">
                            <img :src="item.image_url" alt="">
                        </a>
                    </div>
                </slider>
                <div class="index-tab">
                    <router-link tag="div" class="index-tab-item" to="/index/libao">
                        <span class="tab-icon libao"></span>
                        <p class="tab-link">礼包</p>
                    </router-link>
                    <router-link tag="div" class="index-tab-item" to="/index/notice">
                        <span class="tab-icon gonggao"></span>
                        <p class="tab-link">公告</p>
                    </router-link>
                    <router-link tag="div" class="index-tab-item" to="/index/paihang">
                        <span class="tab-icon paihang"></span>
                        <p class="tab-link">排行</p>
                    </router-link>
                    <router-link tag="div" class="index-tab-item" to="/index/kaifu">
                        <span class="tab-icon kaifu"></span>
                        <p class="tab-link">开服</p>
                    </router-link>
                </div>
                <game-list :apps=apps></game-list>
            </div>
        </scroll>
        <router-view></router-view>
    </div>
</template>

<script>
import Slider from '@/base/slider/slider';
import GameList from '@/base/gamelist/gamelist';
import Scroll from '@/base/scroll/scroll';
import { mapGetters } from 'vuex';
import { getIndexInfo } from '@/base/api/indexpage/getindexinfo';

export default {
    data() {
        return {
            isPullUpLoad: false,
            adsList: [],
            apps: [],
        };
    },
    components: {
        Slider,
        GameList,
        Scroll,
    },
    created() {
        this._getIndexInfo();
    },
    mounted() {
        this.$refs.gameindex.style.top = (44 + parseInt(this.statusbar)) + 'px';
    },
    methods: {
        _getIndexInfo() {
            getIndexInfo().then((res) => {
                this.adsList = res.adsList;
                this.apps = res.apps;
                plus.navigator.closeSplashscreen();
            });
        },
    },
    computed: {
        ...mapGetters(['statusbar']),
    },
};
</script>
<style scoped lang="stylus" rel="stylesheet/stylus">
@import '~common/stylus/variable';
@import '~common/stylus/mixin';

.gameindex {
    position: fixed;
    width: 100%;
    top: 44px;
    bottom: 50px;

    .index-wrapper {
        height: 100%;
        overflow: hidden;

        .index-tab {
            position: relative;
            display: flex;
            height: 60px;
            line-height: 50px;
            font-size: $font-size-medium;
            background: $color-theme;
            width: 100%;
            bottom: 0;
            color: $color-text-yellow;
            box-shadow: 0 2px 5px #d1d0d0;

            .index-tab-item {
                flex: 1;
                text-align: center;
                border-right: 1px solid #eeeeee;
                align-items: center;
                flex-direction: column;
                justify-content: center;

                &:last-child {
                    border-right: none;
                }

                .tab-link {
                    line-height: 24px;
                }

                .tab-icon {
                    display: block;
                    width: 18px;
                    height: 18px;
                    background-size: 18px 18px;
                    margin: 0 auto;
                    margin-top: 11px;

                    &.libao {
                        bg-image('libao');
                    }

                    &.gonggao {
                        bg-image('gonggao');
                    }

                    &.paihang {
                        bg-image('paihang');
                    }

                    &.kaifu {
                        bg-image('kaifu');
                    }
                }

                &.router-link-active {
                    background: #f6f6f6;
                }
            }
        }
    }
}
</style>

